package com.swanclouds.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * @author 张立强
 * @version jdk1.8.0
 */
public abstract class Resource implements ResourceEntity {
    
    @JsonProperty("@odata.id")
    private String dataId;

    @JsonProperty("@odata.context")
    private String context;

    @JsonProperty("@odata.type")
    private String type;

    @JsonProperty("Name")
    private String name;

    /**
     * 系统资源的访问路径
     * @return dataId
     */
    public String getDataId() {
        return this.dataId;
    }

    /**
     * 系统资源模型的OData描述信息
     * @return context
     */
    public String getContext() {
        return this.context;
    }

    /**
     * 系统资源的类型
     * @return type
     */
    public String getType() {
        return this.type;
    }

    /**
     * 系统资源的名称
     * @return Name
     */
    public String getName() {
        return this.name;
    }

    @Override
    public String toString() {
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            return objectMapper.writeValueAsString(this);
        } catch (JsonProcessingException e) {
        }
        return "Resource {" +
                "dataId='" + dataId + '\'' +
                ", context='" + context + '\'' +
                ", type='" + type + '\'' +
                ", name='" + name + '\'' +
                '}';
    }
}
